<?php
namespace app\index\controller;
use think\Db;
use think\Session;
use app\index\model\Message_model;
use think\Request;

class Message extends Common
{
    // 站内消息
    public function index()
    {
        // dump(11);die;
    	$rev = new Message_model;
        $res = $rev->getindex();
        return view('index@Message/index',[
            'node' => $res['list'],
            'notice' => $res['notice'],
            'num2' => $res['num2']
            // 'page' => $res['page']
        ]);

    }
    //发布公告
   public function notice()
    {   
        $this->getAuth();

        $rev = new Message_model;
        $res = $rev->getNotice();

        // var_dump($res);die;
        return view('index@Message/notice',[
            'node' => $res['node'],
            'all' => $res['all'],
            'num2' => $res['num2']
        ]);
    }
 
   public function sendNotice()
    {
        $rev = new Message_model;
        $res = $rev->sendNotice();
        if ($res['a']) {
           $this->success('发送成功','Message/index');
       }else{
           $this->error('发送失败','Message/index');
       }
    }

     public function noticesearch()
   {
    $rev = new Message_model;
    $res = $rev->getnoticeSearch();
    // var_dump($res['res']);die;
    return view('index@Message/searchResult',[
            'node' => $res['list'],
            'res' => $res['res'],
            'keyword' => $res['keyword'],
            'num2' => $res['num2'],
            'title' => $res['title']
        ]);
   }

    // 查询已发消息
   public function checkalready($id)
   {
    $rev = new Message_model;
    $res = $rev->getMailalready($id);
    // var_dump($res);die;
        // fj  发件人
        return view('index@Message/email',[
            'node' => $res['node'],
            'mailinfo' => $res['mailinfo'],
            'sj' => $res['sj'],
            'num2' => $res['num2']
        ]);
   }

       // 查看公告消息
    public function checkn($id)
    {
        $rev = new Message_model;
        $res = $rev->getnMailinfo($id);
        // var_dump($res['fjid']);die;
        return view('index@Message/checkn',[
            'node' => $res['node'],
            'mailinfo' => $res['mailinfo'],
            'fj' => $res['fjid']['0']['user_name'],
            'num2' => $res['num2'],
        ]);
    }
 
}
